package WaiBao;

import java.util.Arrays;

public class WeiLiQin {
    public static void main(String[] args) {
        String[] name = {"王泽宇(班长)", "李浩天(学习委员)", "李思远(纪律委员)", "李大壮(体育委员)", "张泽天", "白敬亭", "何大于", "赵则好", "赵乃", "李香甜", "李旺", "韩静",
                "赵黑黑", "杜牧", "王进开", "许嵩", "白敬亭", "吴磊", "李存勖", "李星云", "李柒", "王自力", "师进", "小郎", "马锦旗", "王朝阳", "雷富贵", "王才",
                "李大勇", "魏莉清 (副班长)"};//考生本人: 魏莉清 (副班长)
        int[] Age = {18, 19, 20, 21, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 19, 18, 19, 20};
        double[] S1 = {78, 88, 74, 80, 68, 69, 78, 89, 89, 90, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 88, 79, 82, 92};
        double[] S2 = {98, 85, 69, 68, 88, 77, 68, 99, 90, 60, 80, 74, 87, 75, 65, 65, 86, 79, 66, 68, 92, 71, 95, 85, 75, 84, 77, 68, 91, 91};
        double[] S3 = {71, 76, 90, 85, 79, 69, 78, 89, 80, 60, 93, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 77, 81, 97, 75, 88, 94};

        double jieguo;//代表每个学生的总分
//        double Pingjun;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            jieguo = S1[i] + S2[i] +S3[i];
//            Pingjun = (jieguo* 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + jieguo);
//            System.out.println(name[i] + "的平均分为:" +Pingjun);
//        }
////
////
//        double res = 0,aver = 0;
//        double[] a = new double[30];
//        for (int i = 0; i < 30; i++) {
//           res = S1[i] + S2[i] + S3[i];
//            aver = (res * 1.0) / 3;
//            a[i] = aver;
//        }
//
//        for (int i = 0; i < a.length - 1; i++) {
//            for (int j = 0; j < a.length - i - 1; j++) {
//                if (a[j] < a[j + 1]) {
//                    double tep = a[j];
//                    a[j] = a[j + 1];
//                    a[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(a[i]);
//        }


        double w1 = 0, w2 = 0, w3 = 0;//计算每门课的平均分
        double e1 = 0, e2 = 0, e3 = 0;//计算每门课标准差
        double r1 = 0, r2 = 0, r3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < S1.length; i++) {
            sum2+=S1[i];
        }
        w1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+w1);
        double Sum = 0;
        for (int i = 0; i < S2.length; i++) {
            Sum+=S2[i];
        }
        w2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+w2);
        double sum = 0;
        for (int i = 0; i <S3.length; i++) {
            sum+=S3[i];
        }
        w3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+w3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < S1.length; i++) {
            c1+= (S1[i] - w1)*(S1[i] - w1);
        }
        e1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+e1);

        for (int i = 0; i < S2.length; i++) {
            c2+= (S2[i] - w2)*(S2[i] - w2);
        }
        e2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+e2);

        for (int i = 0; i < S3.length; i++) {
            c3+= (S3[i] - w3)*(S3[i] - w3);
        }
        e3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+e3);
//
//        Arrays.sort(S1);
//        Arrays.sort(S2);
//        Arrays.sort(S3);
//        r1 =( S1[15]+S1[16])*1.0/2;
//        r2 =( S2[15]+S2[16])*1.0/2;
//        r3 =( S3[15]+S3[16])*1.0/2;
//        System.out.println("生物化学的中位数为:"+r1);
//        System.out.println("微生物学的中位数为:"+r2);
//        System.out.println("人体组织解剖学的中位数为:"+r3);
    }
}
